package com.android.mios.adapter;

import java.util.List;
import com.android.mios.R;
import com.android.mios.model.Room;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class RoomPopGridViewAdapter extends BaseAdapter {

	private LayoutInflater mInflater;
	private List<Room> mList;
	private int resource;
	//private Context mContext;
	public static final String TEXT_TITLE = "texttitle";
	int flag = -1;

	public void setFlag(int flag) {
		this.flag = flag;
	}

	public RoomPopGridViewAdapter(Context context, List<Room> data, int resource) {

		mInflater = LayoutInflater.from(context);
		mList = data;
		this.resource = resource;
		//mContext = context;

	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, final ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null)
			convertView = mInflater.inflate(resource, null);

		final Room mRoom = mList.get(position);

		TextView txt_name = (TextView) convertView
				.findViewById(R.id.tv_room_item);

		txt_name.setText(mRoom.toString());

		return convertView;
	}
}
